package com.example.demo.controller;

import com.example.demo.request.DataRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

/**
 * @author calwen
 * @since 2023/5/29
 */
@Slf4j
@RestController
@RequestMapping("/debug")
public class DebugController {
    @Value("${test.name}")
    String name;

    @GetMapping(value = "/data2")
    public String get(DataRequest dataRequest) {
        log.info("get() === > \n  " + dataRequest);
        return "ok";
    }

    @GetMapping(value = "/data3")
    public String get3() {
        return name;
    }

    @GetMapping(value = "/shutdown")
    public String shutdown() throws InterruptedException {
        Thread thread = new Thread(() -> {
            while (true) {
                System.out.println(" running ~");
            }
        });
        thread.start();
        Thread.sleep(5000);
        System.out.println("5000 ok");
        thread.stop();
        return "ok";
    }


    @GetMapping("/callback/receive")
    public String test3(@RequestBody Object request) {
        log.info("[接受xpay回调] data={}", request);
        return "success";
    }

    @PostMapping("/callback/receive")
    public String test32(@RequestBody Object request) {
        log.info("[接受xpay回调] data={}", request);
        return "success";
    }


    /**
     * 字段定义	类型	字段名称	备注
     * adpid	String	DCloud广告位id
     * provider	String	广告服务商	wm、csj、ks、gdt、sigmob
     * platform	String	平台	iOS、Android
     * sign	String	签名
     * trans_id	String	交易id	完成观看的唯一交易ID
     * user_id	String	用户id	调用SDK透传，应用对用户的唯一标识
     * extra	String	自定义数据	调用SDK传入并透传，如无需要则为空
     */

    //    @PostMapping(value = "/data2")
    //    public String get2() {
    //        log.info("get2() ");
    //        return "ok";
    //    }


}
